local main_state = require("main_state")
-- local luajava = require("luajava")

local header = {
	type = 0,
	name = "kurwonator",
	w = 2560,
	h = 1440,
	loadend = 3000,
	playstart = 1500,
	scene = 3600000,
	input = 500,
	close = 1000,
	fadeout = 100,
	property = {
		{
			name = "Playside",
			def = "Left",
			item = {
				{ name = "Left",  op = 910 },
				{ name = "Right", op = 911 },
			}
		},
	},
	filepath = {
		{ name = "judge",      path = "judge/*.png" },
		{ name = "bomb",       path = "bomb/*.png" },
		{ name = "pomyuchara", path = "pomyu/*" }
	},
	offset = {
		{ name = "Wysokosc judgementow", id = 69, x = false, y = true, w = false, h = false, r = false, a = false },
	}
}

local function main()
	local skin = {}
	for k, v in pairs(header) do
		skin[k] = v
	end

	--[[ local geo = {
	note_w = {88, 68, 88, 68, 88, 68, 88, 156},
	note_x = {162, 256, 330, 424, 498, 592, 666, 0},
	lane_bg = {14, 5, 14, 5, 14, 5, 14, 5}
} ]]

	local geo = {
		note_w = { 88, 68, 88, 68, 88, 68, 88, 156 },
		note_x = {},
		lane_bg = { 14, 5, 14, 5, 14, 5, 14, 5 },
		space = 4
	}


	if skin_config.option["Playside"] == 910 then
		-- Start with the last element in the specified order as the initial position (index 8)
		geo.note_x[1] = geo.note_w[8] + geo.space

		-- Populate note_x according to the specified order
		for i = 2, #geo.note_w do
			local prev_index = (i - 2 + #geo.note_w) % #geo.note_w + 1
			geo.note_x[i] = geo.note_x[i - 1] + geo.note_w[prev_index] + geo.space
		end

		-- Set final position to 0 for the start of the table
		geo.note_x[8] = 0
	else
		geo.note_x[1] = 0 -- Start the first element at position 0

		for i = 2, #geo.note_w do
			geo.note_x[i] = geo.note_x[i - 1] + geo.note_w[i - 1] + geo.space
		end
	end


	local playfieldWidth = 0
	for _, width in ipairs(geo.note_w) do
		playfieldWidth = playfieldWidth + width
	end
	playfieldWidth = playfieldWidth + geo.space * (#geo.note_w - 1)

	local playfieldOrigin = 1280 - (playfieldWidth / 2)

	local cheatCoverOn = function() return main_state.event_index(55) == 2 and main_state.option(273) end


	local loopgif = {
		cycle = 60000 * 2 / main_state.number(92)
	}

	local g = {
		judge_y = 656,
		lane_origin_x = playfieldOrigin,
		lanes_width = playfieldWidth,
		lanes_center_x = 1280,
		lane_origin_y = 476,
	}

	local function get_stage()
		local curr_stage = 0
		repeat
			curr_stage = curr_stage + 1
		until (main_state.option(279 + curr_stage) or curr_stage == 3)
		if main_state.option(289) then curr_stage = 4 end
		return curr_stage
	end

	local function get_course()
		local in_course = false
		if main_state.option(290) then
			in_course = true
		end
		return in_course
	end


	local function get_lamp()
		local total_notes = main_state.number(106)
		local max_combo = main_state.number(105)
		local count_good = main_state.number(112)
		local count_great = main_state.number(111)
		local current_gauge = main_state.gauge_type()
		local gauge_percent = main_state.number(107)
		local combobreak = main_state.number(425)

		local fc_flag = false
		if combobreak == 0 then fc_flag = true end

		local perf_flag = false
		if fc_flag and count_good == 0 then perf_flag = true end

		local max_flag = false
		if perf_flag and count_great == 0 then max_flag = true end

		local exh_flag = false
		if current_gauge == 4 then exh_flag = true end

		local hard_flag = false
		if current_gauge == 3 then hard_flag = true end

		local groove_flag = false
		if current_gauge == 2 and gauge_percent >= 80 then groove_flag = true end

		local easy_flag = false
		if current_gauge == 1 and gauge_percent >= 80 then easy_flag = true end

		local assisteasy_flag = false
		if current_gauge == 0 and gauge_percent > 60 then assisteasy_flag = true end

		local in_course = get_course()
		local stage = get_stage()

		local dan_pass = false
		if in_course == true and stage ~= 4 and main_state.gauge() * 100 ~= 0 then dan_pass = true end

		local dan_clear = false
		if in_course == true and stage == 4 and main_state.gauge() * 100 ~= 0 then dan_clear = true end

		local clear_type = "FAILED"
		if assisteasy_flag then clear_type = "ASSISTED EASY CLEAR" end
		if easy_flag then clear_type = "EASY CLEAR" end
		if groove_flag then clear_type = "CLEAR" end
		if hard_flag then clear_type = "HARD CLEAR" end
		if exh_flag then clear_type = "EX-HARD CLEAR" end
		if fc_flag then clear_type = "FULL COMBO" end
		if perf_flag then clear_type = "PERFECT" end
		if max_flag then clear_type = "MAX" end
		if dan_pass then clear_type = "STAGE CLEAR" end
		if dan_clear then clear_type = "COURSE PASSED" end

		return clear_type
	end

	--[[ 	local clear_colors = {
		["FAILED"] = {138, 0, 0},
		["EASY"] = {0, 215, 15},
		["GROOVE"] = {34, 154, 255},
		["HARD"] = {255, 54, 54},
		["EX-HARD"] = {255, 253, 67},
		["FULL COMBO"] = {120, 255, 247},
		["PERFECT"] = {251, 230, 255},
		["MAX"] = {255, 255, 255}


	}

local function get_red()
	local red = {
		["FAILED"] = 138,
		["EASY"] = 0,
		["GROOVE"] = 34,
		["HARD"] = 255,
		["EX-HARD"] = 255,
		["FULL COMBO"] = 120,
		["PERFECT"] = 251,
		["MAX"] = 255
	}

	return red[get_lamp()]
end ]]

	local function get_rank_text()
		local rank = {
			[1] = "AAA",
			[2] = "AA",
			[3] = "A",
			[4] = "B",
			[5] = "C",
			[6] = "D",
			[7] = "E",
			[8] = "F"
		}
		local gradeop = 0
		repeat
			gradeop = gradeop + 1
		until main_state.option(299 + gradeop)
		return rank[gradeop]
	end


	local itg = {
		"fan", "wfa", "exc", "gre", "dec", "wof", "mis"
	}

	local function check_nil(txt)
		ret = ""
		if txt ~= nil
		then
			ret = txt .. " "
		end
		return ret
	end

	local furu_title = main_state.text(10)
	local zanra = main_state.text(13)

	local extract1 = furu_title:gsub('%([^)]*%)', "")
	local extract2 = extract1:gsub('%[[^)]*%]', "")
	local extract3 = extract2:gsub('%-[^)]*%-', "")
	local extract4 = extract3:gsub('%<[^)]*%>', "")
	local extract5 = extract4:gsub('%~[^)]*%~', "")
	local extract_title = extract5:gsub('%（[^)]*%）', "")

	local extract_sub1 = furu_title:match('%([^)]*%)')
	local extract_sub2 = furu_title:match('%[[^)]*%]')
	local extract_sub3 = furu_title:match('%（[^)]*%）')
	local extract_sub4 = furu_title:match('%-[^)]*%-')
	local extract_sub5 = furu_title:match('%<[^)]*%>')
	local extract_sub6 = furu_title:match('%~[^)]*%~')

	local extract_gen1 = zanra:match('%([^)]*%)')
	local extract_gen2 = zanra:match('%[[^)]*%]')
	local extract_gen3 = zanra:match('%（[^)]*%）')
	local extract_gen4 = zanra:match('%-[^)]*%-')

	local extract_titlesub = check_nil(extract_sub1) ..
		check_nil(extract_sub3) ..
		check_nil(extract_sub4) .. check_nil(extract_sub5) .. check_nil(extract_sub2) .. check_nil(extract_sub6)
	local extract_genresub = check_nil(extract_gen1) ..
		check_nil(extract_gen2) .. check_nil(extract_gen3) .. check_nil(extract_gen4)
	local extract_subtitle = extract_titlesub .. extract_genresub .. check_nil(main_state.text(11))

	local ex_zan1 = zanra:gsub('%([^)]*%)', "")
	local ex_zan2 = ex_zan1:gsub('%[[^)]*%]', "")
	local ex_zan3 = ex_zan2:gsub('%-[^)]*%-', "")
	local extract_genre = ex_zan3:gsub('%（[^)]*%）', "")

	local function append_all(list, list1)
		for i, v in ipairs(list1) do
			table.insert(list, v)
		end
	end

	local function get_diff()
		curr_diff = 6
		repeat
			curr_diff = curr_diff - 1
		until main_state.option(150 + curr_diff)
		return curr_diff
	end

	local function get_play()
		curr_play = "blank"
		if main_state.option(33) then
			curr_play = "play_1"
		elseif main_state.option(84) then
			curr_play = "play_2"
		elseif main_state.option(1080) then
			curr_play = "play_3"
		end
		return curr_play
	end

	local ribbon = { x = 0, y = 1400, w = 200, h = 40 }

	local function get_raise()
		raise = 0
		if ribbon.y + ribbon.h >= 1080 then
			raise = -ribbon.h
		else
			raise = ribbon.h
		end
		return raise
	end

	skin.source = {
		{ id = "src-notes",                path = "note.png" },
		{ id = "gauge",                    path = "gauge.png" },
		{ id = "src-judges",               path = "judge/*.png" },
		{ id = "src-bomb",                 path = "bomb/sg701.png" },
		{ id = "src-laser",                path = "laser.png" },
		{ id = "src-fs",                   path = "fs.png" },
		{ id = "src-fs-2x",                path = "fs_2x.png" },
		{ id = "src-wmix",                 path = "mainparts.png" },
		{ id = "src-peepo",                path = "pipo.png" },
		{ id = "src-bpm",                  path = "bpm.png" },
		{ id = "src-a",                    path = "a.png" },
		{ id = "src-frame",                path = "frame.png" },
		{ id = "src-badge",                path = "raja_effector.png" },
		{ id = "src-hell",                 path = "hell.png" },
		{ id = "src-kurwa",                path = "kurwa-small.png" },
		{ id = "src-tactics",              path = "itg_judge/Tactics.png" },
		{ id = "src-wendy",                path = "itg_judge/Wendy.png" },
		{ id = "src-fail-gradient",        path = "fail.png" },
		{ id = "src-lilith",               path = "lilith.png" },
		{ id = "src-copyduck-pg",          path = "Copyduck/i_pg.png" },
		{ id = "src-copyduck-gr",          path = "Copyduck/i_gr.png" },
		{ id = "src-copyduck-gd",          path = "Copyduck/i_gd.png" },
		{ id = "src-copyduck-bd",          path = "Copyduck/i_bd.png" },
		{ id = "src-copyduck-pr",          path = "Copyduck/i_pr.png" },
		{ id = "src-wendycursed",          path = "wendy_cursed.png" },
		{ id = "src-kotomi",               path = "kotomi.png" },
		{ id = "src-kotomi2",              path = "kotomi2.png" },
		{ id = "src-vertgauge",            path = "vert_gauge.png" },
		{ id = "src-vertgauge-2x",         path = "vert_gauge_2x.png" },
		{ id = "src-ribbons",              path = "ribbons.png" },
		-- { id = "src-kotomiszefowa",        path = "kotomi szefowa.png" },
		{ id = "src-pmchara",              path = "pomyu/*" },
		{ id = "src-hdjudge-pg-f",         path = "HDjudge/PG_F.png" },
		{ id = "src-hdjudge-gr-f",         path = "HDjudge/GR_F2.png" },
		{ id = "src-hdjudge-gd-f",         path = "HDjudge/GD_F2.png" },
		{ id = "src-hdjudge-bd-f",         path = "HDjudge/BD_F2.png" },
		{ id = "src-hdjudge-pr-f",         path = "HDjudge/PR_F2.png" },
		{ id = "src-hdjudge-pg-n",         path = "HDjudge/PG_N.png" },
		{ id = "src-hdjudge-gr-n",         path = "HDjudge/GR_N2.png" },
		{ id = "src-judgestats-2x",        path = "judgestats-2x.png" },
		{ id = "src-judgestats-pgreat-2x", path = "judgestats-pgreat-2x.png" },
		{ id = "src-numbers-2x",           path = "numbers-2x.png" },
		{ id = "src-graph-target",         path = "graph/target.png" },
		{ id = "src-graph-mybest",         path = "graph/mybest.png" },
		{ id = "src-graph-current",        path = "graph/current.png" },
		{ id = "src-graph-text",           path = "graph/text.png" },
		{ id = "src-remi-start",           path = "remi-s-progress/remi_top.png" },
		{ id = "src-remi-bg",              path = "remi-s-progress/remi_long.png" },
		{ id = "src-remi-progress",        path = "remi-s-progress/remi_bar.png" },
		{ id = "src-weed",                 path = "weed.png" },
		{ id = "src-judgediff",            path = "judgerank.png" }
	}

	skin.font = {
		-- { id = "fnt-title",                 path = "oadx_font/00/font.fnt" },
		-- { id = "fnt-genre",                 path = "oadx_font/01/font.fnt" },
		-- { id = "fnt-subtitle",              path = "oadx_font/03/font.fnt" },
		-- { id = "fnt-subartist",             path = "oadx_font/04/font.fnt" },
		{ id = "fnt-title-girlishcafe",     path = "fonts/00girlishcafe/font.fnt" },
		{ id = "fnt-genre-girlishcafe",     path = "fonts/01girlishcafe/font.fnt" },
		{ id = "fnt-subtitle-girlishcafe",  path = "fonts/03girlishcafe/font.fnt" },
		{ id = "fnt-subartist-girlishcafe", path = "fonts/04girlishcafe/font.fnt" },
		{ id = 0,                           path = "mgenplus-1c-bold.ttf" }
	}

	skin.text = {
		-- { id = "title",     font = "fnt-title",     size = 160,                               align = 1,    overflow = 1, constantText = extract_title },
		-- { id = "genre",     font = "fnt-genre",     size = 44,                                align = 1,    overflow = 1, constantText = extract_genre },
		-- { id = "subtitle",  font = "fnt-subtitle",  size = 60,                                align = 1,    overflow = 1, constantText = extract_subtitle },
		-- { id = "artist",    font = "fnt-subtitle",  size = 60,                                align = 1,    overflow = 1, ref = 14 },
		-- { id = "subartist", font = "fnt-subartist", size = 40,                                align = 1,    overflow = 1, ref = 15 },
		-- { id = "table",     font = "fnt-title",     size = 640,                               align = 1,    overflow = 1, ref = 1002 },
		{ id = "title",     font = "fnt-title-girlishcafe",     size = 50,                                align = 1,    overflow = 1, constantText = extract_title },
		{ id = "genre",     font = "fnt-genre-girlishcafe",     size = 18,                                align = 1,    overflow = 1, constantText = extract_genre },
		{ id = "subtitle",  font = "fnt-subartist-girlishcafe", size = 14,                                align = 1,    overflow = 1, constantText = extract_subtitle },
		{ id = "artist",    font = "fnt-subtitle-girlishcafe",  size = 14,                                align = 1,    overflow = 1, ref = 14 },
		{ id = "subartist", font = "fnt-subartist-girlishcafe", size = 14,                                align = 1,    overflow = 1, ref = 15 },
		{ id = "table",     font = "fnt-genre-girlishcafe",     size = 18,                                align = 1,    overflow = 1, ref = 1002 },

		{ id = "clear",     font = 0,                           value = function() return get_lamp() end, overflow = 1, size = 48,    align = 1,                      filter = 1 },
		{
			id = "grade",
			font = 0,
			value = function()
				if main_state.number(101) > 0 then
					return
						get_rank_text()
				else
					return ""
				end
			end,
			overflow = 1,
			size = 72,
			align = 1,
			filter = 1
		},
		{ id = "ex",   font = 0, constantText = "EX",                                  size = 24, align = 1 },
		{ id = "bp",   font = 0, constantText = "BP",                                  size = 24, align = 1 },
		{ id = "cb",   font = 0, constantText = "CB",                                  size = 24, align = 1 },
		{ id = "fast", font = 0, constantText = "FAST",                                size = 24, align = 1 },
		{ id = "slow", font = 0, constantText = "SLOW",                                size = 24, align = 1 },

		{ id = "ex-n", font = 0, value = function() return main_state.number(171) end, size = 48, align = 1 },
		{ id = "bp-n", font = 0, value = function() return main_state.number(427) end, size = 48, align = 1 },
		{ id = "cb-n", font = 0, value = function() return main_state.number(425) end, size = 48, align = 1 },
		{ id = "fa-n", font = 0, value = function() return main_state.number(423) end, size = 48, align = 1 },
		{ id = "sl-n", font = 0, value = function() return main_state.number(424) end, size = 48, align = 1 },

	}

	base_height = g.judge_y + 50
	shadow_y = base_height - 3
	lane_mid = g.lane_origin_x + g.lanes_width / 2
	shadow_x = lane_mid + 3
	movenum = 30
	timerTripped = 0

	skin.customTimers = {
		{
			id = 10101,
			timer = function()
				if timerTripped == 0 then
					if (main_state.gauge() * 100 == 0 and main_state.timer(46) ~= main_state.timer_off_value and main_state.option(290)) then
						timerTripped = 1
						return main_state.time()
					else
						return main_state.timer_off_value
					end
				else
					return main_state.timer(10101)
				end
			end
		}
	}

	skin.image = {}

	append_all(skin.image, {
		{ id = "note-w",              src = "src-notes",         x = 1,    w = 1,    h = 1 },
		{ id = "note-s",              src = "src-notes",         w = 1,    h = 1 },
		{ id = "note-b",              src = "src-notes",         x = 2,    w = 1,    h = 1 },
		{ id = "note-w2",             src = "src-notes",         x = 9,    w = 1,    h = 1 },
		{ id = "note-s2",             src = "src-notes",         x = 8,    w = 1,    h = 1 },
		{ id = "note-b2",             src = "src-notes",         x = 10,   w = 1,    h = 1 },
		{ id = "a bomb",              src = "src-notes",         x = 4,    w = 1,    h = 1 },
		{ id = "line",                src = "src-notes",         x = 4,    w = 1,    h = 1 },
		{ id = "judge-fast",          src = "src-fs",            x = 60,   y = 32,   w = 60,  h = 18 },
		{ id = "judge-slow",          src = "src-fs",            x = 120,  y = 32,   w = 60,  h = 18 },
		{ id = "judge-fast-2x",       src = "src-fs-2x",         w = 150,  h = 40 },
		{ id = "judge-slow-2x",       src = "src-fs-2x",         y = 40,   w = 150,  h = 40 },
		{ id = "fail-gradient",       src = "src-fail-gradient", x = 0,    y = 0,    w = 30,  h = 1 },
		{ id = "kotomi",              src = "src-kotomi",        w = 1000, h = 1000 },
		{ id = "kotomi2",             src = "src-kotomi2",       w = 839,  h = 1200 },
		-- { id = "kotomiszefowa",       src = "src-kotomiszefowa", w = 1200, h = 1600 },
		{ id = "song-progress-start", src = "src-remi-start",    x = 0,    y = 0,    w = -1,  h = -1 },
		{ id = "song-progress-bar",   src = "src-remi-bg",       x = 0,    y = 0,    w = -1,  h = -1 },
		{ id = "weed",                src = "src-weed",          w = 2560, h = 1440 },
		{ id = "weed-cover-left",     src = "src-weed",          x = 0,    y = 1138, w = 901, h = 204 },
		{ id = "weed-cover-right",    src = "src-weed",          x = 1659, y = 1138, w = 901, h = 204 }
	})

	for i = 1, 8 do
		table.insert(skin.image, { id = "gauge0-" .. i, src = "gauge", x = i - 1, w = 1, h = 1 })
		table.insert(skin.image, { id = "gauge60-" .. i, src = "gauge", x = i - 1, y = 30, w = 1, h = 1 })
		table.insert(skin.image, { id = "gauge80-" .. i, src = "gauge", x = i - 1, y = 40, w = 1, h = 1 })
	end

	for i = 1, 7 do
		table.insert(skin.image,
			{ id = "tactics-f-" .. itg[i], src = "src-tactics", y = 120 * (i - 1), w = 452, h = 120 })
		table.insert(skin.image,
			{ id = "tactics-s-" .. itg[i], src = "src-tactics", x = 452, y = 120 * (i - 1), w = 452, h = 120 })
	end



	append_all(skin.image, {
		{ id = "judgef-pg",            src = "src-judges",               y = 13,   w = 245,       h = 225,   divy = 3,              cycle = 100 },
		{ id = "judgef-gr",            src = "src-judges",               y = 238,  w = 245,       h = 150,   divy = 2,              cycle = 80 },
		{ id = "judgef-gd",            src = "src-judges",               y = 388,  w = 245,       h = 150,   divy = 2,              cycle = 80 },
		{ id = "judgef-bd",            src = "src-judges",               x = 245,  y = 388,       w = 245,   h = 150,               divy = 2,   cycle = 80 },
		{ id = "judgef-pr",            src = "src-judges",               x = 490,  y = 388,       w = 245,   h = 150,               divy = 2,   cycle = 80 },

		{ id = "hdjudge-pg-f",         src = "src-hdjudge-pg-f",         w = 490,  h = 150,       divy = 1,  cycle = 100 },
		{ id = "hdjudge-gr-f",         src = "src-hdjudge-gr-f",         w = 490,  h = 150,       divy = 1,  cycle = 80 },
		{ id = "hdjudge-gd-f",         src = "src-hdjudge-gd-f",         w = 490,  h = 150,       divy = 1,  cycle = 80 },
		{ id = "hdjudge-bd-f",         src = "src-hdjudge-bd-f",         w = 490,  h = 150,       divy = 1,  cycle = 80 },
		{ id = "hdjudge-pr-f",         src = "src-hdjudge-pr-f",         w = 490,  h = 150,       divy = 1,  cycle = 80 },

		{ id = "laser",                src = "src-laser",                w = 1,    h = 250 },
		{ id = "peepo",                src = "src-peepo",                w = 96,   h = 2016,      divy = 21, cycle = 1250 },
		{ id = "judgelineflash",       src = "src-wmix",                 y = 54,   w = 377,       h = 63 },
		{ id = "mainbpm-t",            src = "src-wmix",                 x = 308,  y = 140,       w = 58,    h = 17 },
		{ id = "minbpm-t",             src = "src-wmix",                 x = 264,  y = 143,       w = 38,    h = 14 },
		{ id = "maxbpm-t",             src = "src-wmix",                 x = 222,  y = 143,       w = 38,    h = 14 },
		{ id = "a",                    src = "src-a",                    w = 18,   h = 16 },
		{ id = "graphframe",           src = "src-frame",                x = 1447, y = 690 + 378, w = 172,   h = 516 - 378 },
		{ id = "badge",                src = "src-badge",                w = 240,  h = 40 },
		{ id = "judgestats",           src = "src-wmix",                 x = 321,  y = 162,       w = 145,   h = 107 },
		{ id = "judgestats-2x",        src = "src-judgestats-2x",        y = 2,    w = 290,       h = 214 },
		{ id = "judgestats-pgreat",    src = "src-wmix",                 x = 325,  y = 284,       w = 58,    h = 36,                divy = 3,   cycle = 120 },
		{ id = "judgestats-pgreat-2x", src = "src-judgestats-pgreat-2x", w = 116,  h = 72,        divy = 3,  cycle = 120 },
		{ id = "kurwa",                src = "src-kurwa",                w = 480,  h = 14405,     divy = 33, cycle = 1428,          timer = 3 },
		{ id = "lilith",               src = "src-lilith",               w = 6720, h = 560,       divx = 12, cycle = loopgif.cycle, timer = 41 },
		{ id = "copyduck-pg",          src = "src-copyduck-pg",          w = 350,  h = 300,       divy = 3,  cycle = 100 },
		{ id = "copyduck-gr",          src = "src-copyduck-gr",          w = 350,  h = 100 },
		{ id = "copyduck-gd",          src = "src-copyduck-gd",          w = 350,  h = 100 },
		{ id = "copyduck-bd",          src = "src-copyduck-bd",          w = 350,  h = 100 },
		{ id = "copyduck-pr",          src = "src-copyduck-pr",          w = 350,  h = 100 },
		{ id = "gajga-pion-r1",        src = "src-vertgauge-2x",         x = 0,    y = 42,        w = 56,    h = 14 },
		{ id = "gajga-pion-r2",        src = "src-vertgauge-2x",         x = 0,    y = 14,        w = 56,    h = 14 },
		{ id = "gajga-pion-b1",        src = "src-vertgauge-2x",         x = 56,   y = 42,        w = 56,    h = 14 },
		{ id = "gajga-pion-b2",        src = "src-vertgauge-2x",         x = 56,   y = 14,        w = 56,    h = 14 },
		{ id = "gajga-pion-a1",        src = "src-vertgauge-2x",         x = 56,   y = 28,        w = 56,    h = 14 },
		{ id = "gajga-pion-a2",        src = "src-vertgauge-2x",         x = 56,   y = 0,         w = 56,    h = 14 },
		{ id = "gajga-pion-y1",        src = "src-vertgauge-2x",         x = 112,  y = 42,        w = 56,    h = 14 },
		{ id = "gajga-pion-y2",        src = "src-vertgauge-2x",         x = 112,  y = 14,        w = 56,    h = 14 },
		{ id = "gajga-pion-w1",        src = "src-vertgauge-2x",         x = 112,  y = 28,        w = 56,    h = 14 },
		{ id = "gajga-pion-w2",        src = "src-vertgauge-2x",         x = 112,  y = 0,         w = 56,    h = 14 },
		{ id = "ribbon_blank",         src = "src-ribbons",              x = 800,  y = 360,       w = 200,   h = 40 },
		-- randoms
		{ id = "ribbon_random_1",      src = "src-ribbons",              x = 0,    y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_random_2",      src = "src-ribbons",              x = 0,    y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_random_3",      src = "src-ribbons",              x = 0,    y = 80,        w = 200,   h = 40 },
		{ id = "ribbon_random_4",      src = "src-ribbons",              x = 0,    y = 120,       w = 200,   h = 40 },
		{ id = "ribbon_random_5",      src = "src-ribbons",              x = 0,    y = 160,       w = 200,   h = 40 },
		{ id = "ribbon_random_6",      src = "src-ribbons",              x = 0,    y = 200,       w = 200,   h = 40 },
		{ id = "ribbon_random_7",      src = "src-ribbons",              x = 0,    y = 240,       w = 200,   h = 40 },
		{ id = "ribbon_random_8",      src = "src-ribbons",              x = 0,    y = 280,       w = 200,   h = 40 },
		{ id = "ribbon_random_9",      src = "src-ribbons",              x = 0,    y = 320,       w = 200,   h = 40 },
		{ id = "ribbon_random_a",      src = "src-ribbons",              x = 0,    y = 360,       w = 200,   h = 40 },
		-- gauges
		{ id = "ribbon_gauge_1",       src = "src-ribbons",              x = 200,  y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_gauge_2",       src = "src-ribbons",              x = 200,  y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_gauge_3",       src = "src-ribbons",              x = 200,  y = 80,        w = 200,   h = 40 },
		{ id = "ribbon_gauge_4",       src = "src-ribbons",              x = 200,  y = 120,       w = 200,   h = 40 },
		{ id = "ribbon_gauge_5",       src = "src-ribbons",              x = 200,  y = 160,       w = 200,   h = 40 },
		{ id = "ribbon_gauge_6",       src = "src-ribbons",              x = 200,  y = 200,       w = 200,   h = 40 },
		-- difficulties
		{ id = "ribbon_diff_0",        src = "src-ribbons",              x = 400,  y = 200,       w = 200,   h = 40 },
		{ id = "ribbon_diff_1",        src = "src-ribbons",              x = 400,  y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_diff_2",        src = "src-ribbons",              x = 400,  y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_diff_3",        src = "src-ribbons",              x = 400,  y = 80,        w = 200,   h = 40 },
		{ id = "ribbon_diff_4",        src = "src-ribbons",              x = 400,  y = 120,       w = 200,   h = 40 },
		{ id = "ribbon_diff_5",        src = "src-ribbons",              x = 400,  y = 160,       w = 200,   h = 40 },
		-- LN modes
		{ id = "ribbon_ln_1",          src = "src-ribbons",              x = 600,  y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_ln_2",          src = "src-ribbons",              x = 600,  y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_ln_3",          src = "src-ribbons",              x = 600,  y = 80,        w = 200,   h = 40 },
		-- play mods
		{ id = "ribbon_play_1",        src = "src-ribbons",              x = 800,  y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_play_2",        src = "src-ribbons",              x = 800,  y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_play_3",        src = "src-ribbons",              x = 800,  y = 80,        w = 200,   h = 40 },
		-- GAS
		{ id = "ribbon_gas_1",         src = "src-ribbons",              x = 200,  y = 240,       w = 200,   h = 40 },
		-- course/dan
		{ id = "ribbon_course_1",      src = "src-ribbons",              x = 1200, y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_course_2",      src = "src-ribbons",              x = 1200, y = 40,        w = 200,   h = 40 },
		-- course stages
		{ id = "ribbon_stage_1",       src = "src-ribbons",              x = 1000, y = 0,         w = 200,   h = 40 },
		{ id = "ribbon_stage_2",       src = "src-ribbons",              x = 1000, y = 40,        w = 200,   h = 40 },
		{ id = "ribbon_stage_3",       src = "src-ribbons",              x = 1000, y = 80,        w = 200,   h = 40 },
		--[[ 		{id = "ribbon_stage_4", 	src = "src-ribbons", x = 1000, y = 120, w = 200, h = 40},
		{id = "ribbon_stage_5", 	src = "src-ribbons", x = 1000, y = 160, w = 200, h = 40},
		{id = "ribbon_stage_6", 	src = "src-ribbons", x = 1000, y = 200, w = 200, h = 40},
		{id = "ribbon_stage_7", 	src = "src-ribbons", x = 1000, y = 240, w = 200, h = 40},
		{id = "ribbon_stage_8", 	src = "src-ribbons", x = 1000, y = 280, w = 200, h = 40},
		{id = "ribbon_stage_9", 	src = "src-ribbons", x = 1000, y = 320, w = 200, h = 40}, ]]
		{ id = "ribbon_stage_4",       src = "src-ribbons",              x = 1000, y = 360,       w = 200,   h = 40 },

		{ id = "graph-target",         src = "src-graph-target",         w = 336,  h = 60 },
		{ id = "graph-mybest",         src = "src-graph-mybest",         w = 336,  h = 60 },
		{ id = "graph-current",        src = "src-graph-current",        w = 336,  h = 60 },
		{ id = "graph-text",           src = "src-graph-text",           w = 344,  h = 272 },
		{ id = "judge-veasy",          src = "src-judgediff",            y = 0,    w = 204,       h = 24 },
		{ id = "judge-easy",           src = "src-judgediff",            y = 24,   w = 204,       h = 24 },
		{ id = "judge-normal",         src = "src-judgediff",            y = 48,   w = 204,       h = 24 },
		{ id = "judge-hard",           src = "src-judgediff",            y = 72,   w = 204,       h = 24 },
		{ id = "judge-vhard",          src = "src-judgediff",            y = 96,   w = 204,       h = 24 },
	})


	skin.imageset = {
		{ id = "gajga0",  value = function() return main_state.gauge_type() end, images = { "gauge0-1", "gauge0-2", "gauge0-3", "gauge0-4", "gauge0-5", "gauge0-6", "gauge0-7", "gauge0-8", "gauge0-9", "gauge0-10" } },
		{ id = "gajga60", value = function() return main_state.gauge_type() end, images = { "gauge60-1", "gauge60-2", "gauge60-3", "gauge60-4", "gauge60-5", "gauge60-6", "gauge60-7", "gauge60-8", "gauge60-9", "gauge60-10" } },
		{ id = "gajga80", value = function() return main_state.gauge_type() end, images = { "gauge80-1", "gauge80-2", "gauge80-3", "gauge80-4", "gauge80-5", "gauge80-6", "gauge80-7", "gauge80-8", "gauge80-9", "gauge80-10" } },
		{
			id = "ribbon_random",
			ref = 42,
			images = {
				"ribbon_random_1", "ribbon_random_2", "ribbon_random_3", "ribbon_random_4", "ribbon_random_5",
				"ribbon_random_6", "ribbon_random_7", "ribbon_random_8", "ribbon_random_9", "ribbon_random_a"
			},
			act = 42
		},
		{
			id = "ribbon_gauge",
			ref = 40,
			images = {
				"ribbon_gauge_1", "ribbon_gauge_2", "ribbon_gauge_3", "ribbon_gauge_4", "ribbon_gauge_5",
				"ribbon_gauge_6"
			},
			act = 40
		},
		{
			id = "ribbon_ln",
			ref = 308,
			images = {
				"ribbon_ln_1", "ribbon_ln_2", "ribbon_ln_3"
			},
			act = 308
		},
		{
			id = "ribbon_gas",
			ref = 78,
			images = {
				"ribbon_blank", "ribbon_gas_1", "ribbon_gas_1", "ribbon_gas_1", "ribbon_gas_1"
			},
			act = 78
		}
	}

	skin.pmchara = {
		{ id = "pmchara", src = "src-pmchara" }
	}

	local rate_prediction = 0
	local rate_prediction_afterdot = 0

	skin.value = {
		{ id = "judgen-pg",      src = "src-judges",       x = 247,  y = 13,  w = 440,   h = 225,   divx = 10,   divy = 3,   cycle = 100, digit = 6,      ref = 75 },
		{ id = "judgen-gr",      src = "src-judges",       x = 247,  y = 238, w = 440,   h = 150,   divx = 10,   divy = 2,   cycle = 80,  digit = 6,      ref = 75 },
		{ id = "judgen-gd",      src = "src-judges",       x = 247,  y = 238, w = 440,   h = 150,   divx = 10,   divy = 2,   cycle = 80,  digit = 6,      ref = 75 },
		{ id = "hdjudge-pg-n",   src = "src-hdjudge-pg-n", w = 880,  h = 150, divx = 10, divy = 1,  cycle = 100, digit = 6,  ref = 75 },
		{ id = "hdjudge-gr-n",   src = "src-hdjudge-gr-n", w = 880,  h = 150, divx = 10, divy = 1,  cycle = 80,  digit = 6,  ref = 75 },
		{ id = "hdjudge-gd-n",   src = "src-hdjudge-gr-n", w = 880,  h = 150, divx = 10, divy = 1,  cycle = 80,  digit = 6,  ref = 75 },
		{ id = "judgen-bd",      src = "src-judges",       x = 0,    y = 0,   w = 1,     h = 1,     divx = 10,   divy = 2,   cycle = 80,  digit = 6,      ref = 75 },
		{ id = "judgen-pr",      src = "src-judges",       x = 0,    y = 0,   w = 1,     h = 1,     divx = 10,   divy = 2,   cycle = 80,  digit = 6,      ref = 75 },
		{ id = "ghost-n",        src = "src-wmix",         y = 142,  w = 180, h = 36,    divx = 12, divy = 2,    ref = 108,  digit = 4,   zeropadding = 1 },
		{ id = "ghost-n-2x",     src = "src-numbers-2x",   y = 36,   w = 360, h = 72,    divx = 12, divy = 2,    ref = 108,  digit = 4,   zeropadding = 1 },
		{ id = "gn",             src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 313,   digit = 3 },
		{ id = "wn",             src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 14,    digit = 3 },
		{ id = "gn-2x",          src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 313, digit = 3 },
		{ id = "wn-2x",          src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 14,  digit = 3 },
		{ id = "mainbpm",        src = "src-bpm",          w = 319,  h = 22,  divx = 11, ref = 160, digit = 3 },
		{ id = "minbpm",         src = "src-bpm",          y = 28,   w = 209, h = 16,    divx = 11, ref = 91,    digit = 3 },
		{ id = "maxbpm",         src = "src-bpm",          y = 28,   w = 209, h = 16,    divx = 11, ref = 92,    digit = 3 },
		{ id = "ex-now",         src = "src-wmix",         y = 227,  w = 165, h = 18,    divx = 11, digit = 4,   ref = 101 },
		{ id = "ex-best",        src = "src-wmix",         y = 227,  w = 165, h = 18,    divx = 11, ref = 150,   digit = 4 },
		{ id = "ex-target",      src = "src-wmix",         y = 227,  w = 165, h = 18,    divx = 11, ref = 121,   digit = 4 },
		{ id = "diff-best",      src = "src-wmix",         y = 142,  w = 180, h = 36,    divx = 12, divy = 2,    ref = 152,  digit = 4 },
		{ id = "diff-target",    src = "src-wmix",         y = 142,  w = 180, h = 36,    divx = 12, divy = 2,    ref = 108,  digit = 4 },
		{ id = "ex-now-2x",      src = "src-numbers-2x",   w = 330,  h = 36,  divx = 11, digit = 4, ref = 101 },
		{ id = "ex-best-2x",     src = "src-numbers-2x",   w = 330,  h = 36,  divx = 11, ref = 150, digit = 4 },
		{ id = "ex-target-2x",   src = "src-numbers-2x",   w = 330,  h = 36,  divx = 11, ref = 121, digit = 4 },
		{ id = "diff-best-2x",   src = "src-numbers-2x",   y = 36,   w = 360, h = 72,    divx = 12, divy = 2,    ref = 152,  digit = 4 },
		{ id = "diff-target-2x", src = "src-numbers-2x",   y = 36,   w = 360, h = 72,    divx = 12, divy = 2,    ref = 108,  digit = 4 },
		{ id = "stats-pg",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 110,   digit = 4 },
		{ id = "stats-gr",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 111,   digit = 4 },
		{ id = "stats-gd",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 112,   digit = 4 },
		{ id = "stats-bd",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 113,   digit = 4 },
		{ id = "stats-pr",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 426,   digit = 4 },
		{ id = "stats-rt",       src = "src-wmix",         y = 227,  w = 150, h = 18,    divx = 10, ref = 102,   digit = 3 },
		{ id = "stats-pg-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 110, digit = 4 },
		{ id = "stats-gr-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 111, digit = 4 },
		{ id = "stats-gd-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 112, digit = 4 },
		{ id = "stats-bd-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 113, digit = 4 },
		{ id = "stats-pr-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 426, digit = 4 },
		{ id = "stats-rt-2x",    src = "src-numbers-2x",   w = 300,  h = 36,  divx = 10, ref = 102, digit = 3 },
		{ id = "wendy",          src = "src-wendy",        w = 1240, h = 200, divx = 10, ref = 75,  digit = 6,   space = -48 },
		{ id = "wendycursed",    src = "src-wendycursed",  w = 440,  h = 74,  divx = 10, ref = 75,  digit = 6,   space = 22 },
		--{id = "prediction", src = "src-judges", x = 247, y = 13, w = 440, h = 225, divx = 10, divy = 3, cycle = 100, digit = 6, value = function() return rate_prediction end},
		--{id = "prediction_afterdot", src = "src-judges", x = 247, y = 13, w = 440, h = 225, divx = 10, divy = 3, cycle = 100, digit = 6, value = function() return rate_prediction_afterdot end},
	}

	skin.slider = {
		{ id = "szmata",        src = "src-notes",         x = 3, w = 1, h = 1,  angle = 2, range = 964, type = 4 },
		{
			id = "cheatszmata",
			src = "src-notes",
			x = 3,
			w = 1,
			h = 1,
			angle = 2,
			range = 964,
			type = 4,
			value = function()
				if cheatCoverOn then
					local visible_area = 1000 - main_state.number(14)
					local speed_ratio = main_state.number(160) / main_state.number(90)
					return (main_state.number(14) + (visible_area - visible_area * speed_ratio)) / 1000
				end
			end
		},
		{ id = "song-progress", src = "src-remi-progress", x = 0, y = 0, w = -1, h = -1,    angle = 2,   range = 902 - 52, type = 6 }
	}

	skin.graph = {
		{ id = "graph-now",    src = "src-wmix", x = 471, w = 1,  h = 327, type = 110 },
		{ id = "graph-end",    src = "src-wmix", x = 471, w = 1,  h = 327, type = 111 },
		{ id = "graph-end2",   src = "src-wmix", x = 488, w = 44, h = 327, type = 111 },
		{ id = "mybest-bg",    src = "src-wmix", x = 476, w = 1,  h = 327, type = 113 },
		{ id = "target-bg",    src = "src-wmix", x = 480, w = 1,  h = 327, type = 115 },
		{ id = "mybest-bg2",   src = "src-wmix", x = 488, w = 44, h = 327, type = 113 },
		{ id = "target-bg2",   src = "src-wmix", x = 488, w = 44, h = 327, type = 115 },
		{ id = "mybest-now",   src = "src-wmix", x = 476, w = 1,  h = 327, type = 112 },
		{ id = "mybest-first", src = "src-wmix", x = 476, w = 1,  h = 327, type = 110 },
		{ id = "target-now",   src = "src-wmix", x = 480, w = 1,  h = 327, type = 114 },
	}

	skin.judgegraph = {
		{ id = "judgegraph", backTexOff = 1, noGapX = 1, noGap = 1, delay = 100 }
	}

	skin.bpmgraph = {
		{ id = "bpmgraph" }
	}

	skin.judge = {
		{
			id = "judge",
			index = 0,
			images = {
				{
					id = "hdjudge-pg-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-gr-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-gd-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-bd-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-pr-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-pr-f",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 1040, y = 656, w = 490, h = 150 },
						{ time = 500 }
					}
				},
			},
			numbers = {
				{
					id = "hdjudge-pg-n",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-gr-n",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "hdjudge-gd-n",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "judgen-bd",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "judgen-pr",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
				{
					id = "judgen-pr",
					loop = -1,
					timer = 46,
					filter = 1,
					offsets = { 3, 69 },
					dst = {
						{ time = 0,  x = 410, y = 0, w = 88, h = 150 },
						{ time = 500 }
					}
				},
			},
			shift = true
		},
		{
			id = "itg-f",
			index = 0,
			images = {
				{
					id = "tactics-f-fan",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-f-exc",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1242 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-f-gre",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1242 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-f-dec",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1242 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-f-mis",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1242 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-f-wof",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1242 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
			},
			numbers = {
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
			},
			shift = false
		},
		{
			id = "itg-s",
			index = 0,
			images = {
				{
					id = "tactics-s-fan",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-s-exc",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1243 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-s-gre",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1243 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-s-dec",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1243 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-s-mis",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1243 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
				{
					id = "tactics-s-wof",
					loop = -1,
					timer = 46,
					filter = 1,
					op = { 1243 },
					dst = {
						{ time = 0,  x = 1054, y = 686, w = 452, h = 120 },
						{ time = 500 }
					}
				},
			},
			numbers = {
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
				{
					id = "wendy",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 346, y = 400, w = 124, h = 200 },
						{ time = 500 }
					}
				},
			},
			shift = false
		},
		{
			id = "copyduck",
			index = 0,
			images = {
				{
					id = "copyduck-pg",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39, x = 1105, y = 680, w = 350, h = 100 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-gr",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,   x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39,  x = 1105, y = 680, w = 350, h = 100 },
						{ time = 40,  a = 0 },
						{ time = 79 },
						{ time = 80,  a = 255 },
						{ time = 119 },
						{ time = 120, a = 0 },
						{ time = 159 },
						{ time = 160, a = 255 },
						{ time = 199 },
						{ time = 200, a = 0 },
						{ time = 239 },
						{ time = 240, a = 255 },
						{ time = 279 },
						{ time = 280, a = 0 },
						{ time = 319 },
						{ time = 320, a = 255 },
						{ time = 359 },
						{ time = 360, a = 0 },
						{ time = 399 },
						{ time = 400, a = 255 },
						{ time = 439 },
						{ time = 440, a = 0 },
						{ time = 479 },
						{ time = 480, a = 255 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-gd",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,   x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39,  x = 1105, y = 680, w = 350, h = 100 },
						{ time = 40,  a = 0 },
						{ time = 79 },
						{ time = 80,  a = 255 },
						{ time = 119 },
						{ time = 120, a = 0 },
						{ time = 159 },
						{ time = 160, a = 255 },
						{ time = 199 },
						{ time = 200, a = 0 },
						{ time = 239 },
						{ time = 240, a = 255 },
						{ time = 279 },
						{ time = 280, a = 0 },
						{ time = 319 },
						{ time = 320, a = 255 },
						{ time = 359 },
						{ time = 360, a = 0 },
						{ time = 399 },
						{ time = 400, a = 255 },
						{ time = 439 },
						{ time = 440, a = 0 },
						{ time = 479 },
						{ time = 480, a = 255 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-bd",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,   x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39,  x = 1105, y = 680, w = 350, h = 100 },
						{ time = 40,  a = 0 },
						{ time = 79 },
						{ time = 80,  a = 255 },
						{ time = 119 },
						{ time = 120, a = 0 },
						{ time = 159 },
						{ time = 160, a = 255 },
						{ time = 199 },
						{ time = 200, a = 0 },
						{ time = 239 },
						{ time = 240, a = 255 },
						{ time = 279 },
						{ time = 280, a = 0 },
						{ time = 319 },
						{ time = 320, a = 255 },
						{ time = 359 },
						{ time = 360, a = 0 },
						{ time = 399 },
						{ time = 400, a = 255 },
						{ time = 439 },
						{ time = 440, a = 0 },
						{ time = 479 },
						{ time = 480, a = 255 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-pr",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,   x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39,  x = 1105, y = 680, w = 350, h = 100 },
						{ time = 40,  a = 0 },
						{ time = 79 },
						{ time = 80,  a = 255 },
						{ time = 119 },
						{ time = 120, a = 0 },
						{ time = 159 },
						{ time = 160, a = 255 },
						{ time = 199 },
						{ time = 200, a = 0 },
						{ time = 239 },
						{ time = 240, a = 255 },
						{ time = 279 },
						{ time = 280, a = 0 },
						{ time = 319 },
						{ time = 320, a = 255 },
						{ time = 359 },
						{ time = 360, a = 0 },
						{ time = 399 },
						{ time = 400, a = 255 },
						{ time = 439 },
						{ time = 440, a = 0 },
						{ time = 479 },
						{ time = 480, a = 255 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-pr",
					loop = -1,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,   x = 1095, y = 670, w = 370, h = 110, acc = 1 },
						{ time = 39,  x = 1105, y = 680, w = 350, h = 100 },
						{ time = 40,  a = 0 },
						{ time = 79 },
						{ time = 80,  a = 255 },
						{ time = 119 },
						{ time = 120, a = 0 },
						{ time = 159 },
						{ time = 160, a = 255 },
						{ time = 199 },
						{ time = 200, a = 0 },
						{ time = 239 },
						{ time = 240, a = 255 },
						{ time = 279 },
						{ time = 280, a = 0 },
						{ time = 319 },
						{ time = 320, a = 255 },
						{ time = 359 },
						{ time = 360, a = 0 },
						{ time = 399 },
						{ time = 400, a = 255 },
						{ time = 439 },
						{ time = 440, a = 0 },
						{ time = 479 },
						{ time = 480, a = 255 },
						{ time = 500 }
					}
				},
			},
			numbers = {
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 450, w = 44, h = 44, acc = 1, a = 0 },
						{ time = 500 }
					}
				},
			},
			shift = false
		},
		{
			id = "copyduck-n",
			index = 0,
			images = {
				{
					id = "copyduck-pg",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-gr",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-gd",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-bd",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-pr",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
				{
					id = "copyduck-pr",
					loop = 500,
					timer = 46,
					filter = 1,
					dst = {
						{ time = 0,  x = 1105, y = 680, w = 350, h = 100, a = 0 },
						{ time = 500 }
					}
				},
			},
			numbers = {
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
				{
					id = "wendycursed",
					loop = 500,
					timer = 46,
					filter = 1,
					blend = 1,
					dst = {
						{ time = 0,  x = 120, y = 550, w = 44, h = 80, acc = 1 },
						{ time = 40, h = 72 },
						{ time = 499 },
						{ time = 500 }
					}
				},
			},
			shift = false
		},
	}

	skin.note =
	{
		id              = "notes",
		note            = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		lnend           = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		lnstart         = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		lnbody          = { "note-w2", "note-b2", "note-w2", "note-b2", "note-w2", "note-b2", "note-w2", "note-s2" },
		lnbodyActive    = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnend          = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnstart        = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnbody         = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnbodyActive   = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnbodyMiss     = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		hcnbodyReactive = { "note-w", "note-b", "note-w", "note-b", "note-w", "note-b", "note-w", "note-s" },
		mine            = { "a bomb", "a bomb", "a bomb", "a bomb", "a bomb", "a bomb", "a bomb", "a bomb" },
		size            = { 24, 24, 24, 24, 24, 24, 24, 24 },
		group           = {
			{
				id = 'line',
				dst = {
					{ x = 0, y = 0, w = 100, h = 1, a = 0, offset = 3 }
				}
			} },
		time            = {
			{
				id = 'line',
				dst = {
					{ x = 0, y = 0, w = 100, h = 1, a = 0, r = 64, g = 192, b = 192 }
				}
			} },
		bpm             = {
			{
				id = 'line',
				dst = {
					{ x = 0, y = 0, w = 100, h = 1, a = 0, r = 0, g = 192, b = 0 }
				}
			} },
		stop            = {
			{
				id = 'line',
				dst = {
					{ x = 0, y = 0, w = 100, h = 1, a = 0, r = 192, g = 192, b = 0 }
				}
			} }
	}

	skin.note.dst = {}
	for i = 1, 8 do
		skin.note.dst[i] = {
			x = playfieldOrigin + geo.note_x[i],
			y = 476,
			w = geo.note_w[i],
			h = 964,
		}
	end

	local timeInSeconds = main_state.number(1163) * 60 + main_state.number(1164)
	local graphMovementPx = 20
	local densityGraphStart = 903 + 250

	print(timeInSeconds)

	local procent_gajgi = 0
	--local totalex = main_state.number(74) * 2
	--local missedex = 0
	--local prediction_score = 0

	skin.destination = {}

	append_all(skin.destination, {
		{
			id = -111,
			draw = function()
				procent_gajgi = main_state.gauge()
				--missedex = (main_state.number(114) + main_state.number(113) + main_state.number(112)) * 2 + main_state.number(111)
				--prediction_score = totalex - missedex
				--rate_prediction = prediction_score / totalex * 100
				--rate_prediction_afterdot = string.sub((prediction_score / totalex) * 10000, 3, 4)
				--[[ if Gdx.input:isKeyPressed(input.Keys.RIGHT) then
			print("ojoj wcislo mi sie")
		end ]]
			end,
			dst = { time = 0 }
		},
		{
			id = "weed",
			dst = {
				{ w = 2560, h = 1440 }
			}
		},
		{ id = -110, dst = { { x = playfieldOrigin, y = g.lane_origin_y, w = playfieldWidth, h = 2000 } } },
		{
			id = "judgegraph",
			timer = 41,
			loop = -1,
			dst = {
				{ time = 0,                           x = densityGraphStart,                                    y = 100, h = 200, w = graphMovementPx * timeInSeconds },
				{ time = timeInSeconds * 1000 + 2000, x = densityGraphStart - graphMovementPx * (timeInSeconds) }
			}
		},
		{
			id = "bpmgraph",
			timer = 41,
			loop = -1,
			op = { 177 },
			dst = {
				{ time = 0,                           x = densityGraphStart,                                    y = 100, h = 200, w = graphMovementPx * timeInSeconds },
				{ time = timeInSeconds * 1000 + 2000, x = densityGraphStart - graphMovementPx * (timeInSeconds) }
			}
		},
		{
			id = "judgegraph",
			timer = 40,
			loop = -1,
			dst = {
				{ time = 0,    x = 2560,             y = 100, h = 200, w = graphMovementPx * timeInSeconds, acc = 2 },
				{ time = 1500, x = densityGraphStart }
			}
		},
		{
			id = "judgegraph",
			timer = 40,
			loop = -1,
			op = { 177 },
			dst = {
				{ time = 0,    x = 2560,             y = 100, h = 200, w = graphMovementPx * timeInSeconds, acc = 2 },
				{ time = 1500, x = densityGraphStart }
			}
		},
		{
			id = "judgegraph",
			loop = -1,
			timer = 40,
			dst = {
				{ time = 0,   x = 903, y = 100, w = 754, h = 200, acc = 1, a = 127 },
				{ time = 500, x = 0 }
			}
		},
		{
			id = "bpmgraph",
			loop = -1,
			timer = 40,
			op = { 177 },
			dst = {
				{ time = 0,   x = 903, y = 100, w = 754, h = 200, acc = 1, a = 127 },
				{ time = 500, x = 0 }
			}
		},
		{
			id = "weed-cover-left",
			dst = {
				{ x = 0, y = 98, w = 901, h = 204 }
			}
		},
		{
			id = "weed-cover-right",
			dst = {
				{ x = 1659, y = 98, w = 901, h = 204 }
			}
		},
		-- {
		-- 	id = -110,
		-- 	dst = {
		-- 		{ y = 100, w = 903, h = 200 }
		-- 	}
		-- },
		-- {
		-- 	id = -110,
		-- 	dst = {
		-- 		{ x = 1657, y = 100, w = 920, h = 200 }
		-- 	}
		-- },
		--[[ 	{id = "kotomi", filter = 1, dst = {
		{x = 200, w = 500, h = 500, a = 31}
	}}, ]]
		--[[ 	{id = "kotomi2", filter = 1, dst = {
		{w = 839, h = 1200, a = 63}
	}}, ]]
		-- {
		-- 	id = "kotomiszefowa",
		-- 	filter = 1,
		-- 	dst = {
		-- 		{ w = 900, h = 1200, a = 63 }
		-- 	}
		-- },
		{
			id = -111,
			dst = {
				{ x = playfieldOrigin, y = 474, w = playfieldWidth, h = 2 }
			}
		},
		{
			id = -111,
			dst = {
				{ x = playfieldOrigin - 2, y = 474, w = 2, h = 964 }
			}
		},
		{
			id = -111,
			dst = {
				{ x = playfieldOrigin + playfieldWidth, y = 474, w = 2, h = 964 }
			}
		},
		--[[ 	{id = -111, dst = {
		{x = 903 + geo.note_x[8], y = 504, w = geo.note_w[8], r = geo.lane_bg[8], g = geo.lane_bg[8], b = geo.lane_bg[8], h = 964}
	}} ]]
	})
	--lane bg
	--[[ for i = 1, 7 do
	table.insert(skin.destination, {id = -111, dst = {
		{x = 903 + geo.note_x[i], y = 504, w = geo.note_w[i], r = geo.lane_bg[i], g = geo.lane_bg[i], b = geo.lane_bg[i], h = 964}
	}})
	table.insert(skin.destination, {id = -111, dst = {
		{x = 903 + geo.note_x[i] - 4, y = 504, w = 2, h = 964, r = 40, g = 40, b = 40}
	}
	})
end ]]

	local function timer_key_laser(index, onoroff)
		inc = 20
		if onoroff == true then
			inc = 0
		end
		if index == 8 then
			return 100 + inc
		else
			return 100 + index + inc
		end
	end

	for i = 1, 7 do
		table.insert(skin.destination, {
			id = "laser",
			timer = timer_key_laser(i, true),
			blend = 2,
			offset = 3,
			dst = {
				{ x = playfieldOrigin + geo.note_x[i], y = 476, w = geo.note_w[i], h = 125, a = 128 }
			}
		})
		table.insert(skin.destination, {
			id = "laser",
			timer = timer_key_laser(i, false),
			blend = 2,
			loop = -1,
			offset = 3,
			dst = {
				{ time = 0,  x = playfieldOrigin + geo.note_x[i],                     y = 476, w = geo.note_w[i], h = 125, a = 128 },
				{ time = 83, x = playfieldOrigin + geo.note_x[i] + geo.note_w[i] / 2, w = 0,   a = 0 }
			}
		})
	end

	append_all(skin.destination, {
		{
			id = "laser",
			timer = timer_key_laser(8, true),
			blend = 2,
			loop = -1,
			offset = 3,
			dst = {
				{ x = playfieldOrigin + geo.note_x[8], y = 476,                                                 w = geo.note_w[8], h = 175, a = 128 },
				{ time = 83,                           x = playfieldOrigin + geo.note_x[8] + geo.note_w[8] / 2, w = 0,             a = 0 }
			}
		},
		--[[ 	{id = "peepo", op = {80}, blend = 1, filter = 1, dst = {
		{time = 0, x = 903, y = 504, w = 754, h = 754}
	}},
	{id = "peepo", timer = 40, blend = 1, filter = 1, loop = 500, dst = {
		{time = 0, x = 903, y = 504, w = 754, h = 754},
		{time = 500, a = 0}
	}}, ]]
		{
			id = "judgelineflash",
			blend = 2,
			filter = 2,
			timer = 140,
			offset = 3,
			dst = {
				{ time = 0,   x = playfieldOrigin, y = 476, w = playfieldWidth, h = 126, acc = 1 },
				{ time = 700, a = 0,               r = 0 },
				{ time = 1000 }
			}
		},
		--judgeline
		{
			id = -111,
			offset = 3,
			dst = {
				{ x = playfieldOrigin, y = 476, w = playfieldWidth, h = 28, g = 0, b = 0 }
			}
		},
	})

	append_all(skin.destination, {
		{ id = "notes" },
		--cover
		{
			id = "szmata",
			op = { -273 },
			dst = {
				{ x = playfieldOrigin, y = 1440, w = playfieldWidth, h = 964 }
			}
		},
		{
			id = "cheatszmata",
			op = { 273 },
			dst = {
				{ x = playfieldOrigin, y = 1440, w = playfieldWidth, h = 964 }
			}
		},
		{
			id = "gn-2x",
			blend = 1,
			filter = 1,
			loop = 1000,
			op = { 270, -271 },
			dst = {
				{ time = 0,   x = 1235, y = 1400, w = 30, h = 36, r = 0, b = 0 },
				{ time = 1000 }
			}
		},
		{
			id = "gn-2x",
			blend = 1,
			filter = 1,
			loop = 1000,
			op = { 270, 271 },
			offset = 4,
			dst = {
				{ time = 0,   x = 1047, y = 1440, w = 30, h = 36, r = 0, b = 0 },
				{ time = 1000 }
			}
		},
		{
			id = "wn-2x",
			blend = 1,
			filter = 1,
			loop = 1000,
			op = { 270, 271 },
			offset = 4,
			dst = {
				{ time = 0,   x = 1423, y = 1440, w = 30, h = 36 },
				{ time = 1000 }
			}
		},
		{
			id = "judge-vhard",
			op = { 180, 80 },
			offset = 4,
			blend = 1,
			loop = 500,
			dst = {
				{ time = 0,   x = 1178, y = 1440, w = 204, h = 24, acc = 2, a = 0 },
				{ time = 500, y = 1400, a = 255 },
			}
		},
		{
			id = "judge-hard",
			op = { 181, 80 },
			offset = 4,
			blend = 1,
			loop = 500,
			dst = {
				{ time = 0,   x = 1178, y = 1440, w = 204, h = 24, acc = 2, a = 0 },
				{ time = 500, y = 1400, a = 255 },
			}
		},
		{
			id = "judge-normal",
			op = { 182, 80 },
			offset = 4,
			blend = 1,
			loop = 500,
			dst = {
				{ time = 0,   x = 1178, y = 1440, w = 204, h = 24, acc = 2, a = 0 },
				{ time = 500, y = 1400, a = 255 },
			}
		},
		{
			id = "judge-easy",
			op = { 183, 80 },
			offset = 4,
			blend = 1,
			loop = 500,
			dst = {
				{ time = 0,   x = 1178, y = 1440, w = 204, h = 24, acc = 2, a = 0 },
				{ time = 500, y = 1400, a = 255 },
			}
		},
		{
			id = "judge-veasy",
			op = { 184, 80 },
			offset = 4,
			blend = 1,
			loop = 500,
			dst = {
				{ time = 0,   x = 1178, y = 1440, w = 204, h = 24, acc = 2, a = 0 },
				{ time = 500, y = 1400, a = 255 },
			}
		},
		{
			id = "judge-vhard",
			op = { 180 },
			offset = 4,
			loop = 500,
			timer = 40,
			dst = {
				{ time = 0,   x = 1178, y = 1400, w = 204, h = 24, acc = 2, a = 255 },
				{ time = 500, a = 0 }
			}
		},
		{
			id = "judge-hard",
			op = { 181 },
			offset = 4,
			loop = 500,
			timer = 40,
			dst = {
				{ time = 0,   x = 1178, y = 1400, w = 204, h = 24, acc = 2, a = 255 },
				{ time = 500, a = 0 }
			}
		},
		{
			id = "judge-normal",
			op = { 182 },
			offset = 4,
			loop = 500,
			timer = 40,
			dst = {
				{ time = 0,   x = 1178, y = 1400, w = 204, h = 24, acc = 2, a = 255 },
				{ time = 500, a = 0 }
			}
		},
		{
			id = "judge-easy",
			op = { 183 },
			offset = 4,
			loop = 500,
			timer = 40,
			dst = {
				{ time = 0,   x = 1178, y = 1400, w = 204, h = 24, acc = 2, a = 255 },
				{ time = 500, a = 0 }
			}
		},
		{
			id = "judge-veasy",
			op = { 184 },
			offset = 4,
			loop = 500,
			timer = 40,
			dst = {
				{ time = 0,   x = 1178, y = 1400, w = 204, h = 24, acc = 2, a = 255 },
				{ time = 500, a = 0 }
			}
		}
		-- {
		-- 	id = "title",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	timer = 40,
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 640, w = 850, h = 160, r = 127, g = 127, b = 127, acc = 2 },
		-- 		{ time = 750, a = 255,  x = 451 }
		-- 	}
		-- },

	})

	--[[ local function f(x)
  -- normalize
  t = x / 2
  -- cubic bezier
  return (3 * (1 - t)^2 * t + 3 * (1 - t) * t^2 + t^3) * 100
end ]]

	function VertGauge()
		local gauge_width = 700;
		local t = {}
		local groove_angle = 90
		local webcam_groove_x = 1671
		local webcam_groove_y = 476
		local old_timer = 0
		local gauge_interval = 500
		local hp_unk = 0
		local hp_old = 0
		local hp_print = 0
		local time_oldHP = 0
		local time_newHP = 0
		local tremble = 0
		local cache_i = nil
		local cache_notes = nil
		local cache_gt = nil
		local function gauge_cache(i)
			if cache_i ~= i then
				cache_i = i
				local now = main_state.time() / 1000.0
				local gauge = hp_unk
				if main_state.timer(41) ~= main_state.timer_off_value then
					gauge = main_state.gauge()
				elseif main_state.timer(40) ~= main_state.timer_off_value then
					if gauge ~= 100 and now - old_timer > gauge_interval then
						gauge_interval = gauge_interval + (50 * gauge) / 8
						gauge = gauge + 1
						old_timer = now
					end
				end
				if hp_unk ~= gauge then
					hp_old = hp_print
					time_oldHP = now
					time_newHP = now + math.abs(hp_old - gauge) * 10
					hp_unk = gauge
				end
				if hp_old == gauge then
					hp_print = hp_old
				elseif time_oldHP <= now and now <= time_newHP and time_oldHP < time_newHP then
					local ratio = (now - time_oldHP) / (time_newHP - time_oldHP)
					hp_print = (1.0 - ratio) * hp_old + ratio * gauge
				else
					hp_print = (time_oldHP < now) and gauge or hp_old
				end
				cache_notes = math.floor(hp_print / 2)
				tremble = cache_notes - math.random(0, 2)
				cache_gt = main_state.gauge_type()
			end
			local notes = cache_notes
			local cond = (i <= notes) and (i == 1 or i < tremble or i == notes)
			return cond, cache_gt
		end
		for i = 1, 50 do
			i_2 = i - 1
			-- Assist gauge.
			if i < 30 then
				table.insert(t,
					{
						id = "gajga-pion-a2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 0) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-a1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 0) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
			else
				table.insert(t,
					{
						id = "gajga-pion-b2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 0) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-b1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 0) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
			end
			-- Easy and normal gauge.
			if i < 40 then
				table.insert(t,
					{
						id = "gajga-pion-a2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 2) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-a2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 1) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-a1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 2) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-a1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 1) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
			else
				table.insert(t,
					{
						id = "gajga-pion-r2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 2) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-r1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 2) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-b2",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return not c and (gt == 1) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
				table.insert(t,
					{
						id = "gajga-pion-b1",
						filter = 1,
						loop = 1000,
						draw = function() local c, gt = gauge_cache(i); return c and (gt == 1) end,
						dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
							{ time = 500,  a = 0 },
							{ time = 1000, a = 255 }
						}
					})
			end
			-- Hard gauges.
			table.insert(t,
				{
					id = "gajga-pion-r2",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return not c and
							((gt == 3) or (gt == 6))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
			table.insert(t,
				{
					id = "gajga-pion-r1",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return c and
							((gt == 3) or (gt == 6))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
			table.insert(t,
				{
					id = "gajga-pion-y2",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return not c and
							((gt == 4) or (gt == 7))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
			table.insert(t,
				{
					id = "gajga-pion-y1",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return c and
							((gt == 4) or (gt == 7))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
			table.insert(t,
				{
					id = "gajga-pion-w2",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return not c and
							((gt == 5) or (gt == 8))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
			table.insert(t,
				{
					id = "gajga-pion-w1",
					filter = 1,
					loop = 1000,
					draw = function()
						local c, gt = gauge_cache(i); return c and
							((gt == 5) or (gt == 8))
					end,
					dst = { { time = 0, x = webcam_groove_x, y = webcam_groove_y + i_2 * (gauge_width / 50), w = 40, h = gauge_width / 50, a = 0 },
						{ time = 500,  a = 0 },
						{ time = 1000, a = 255 }
					}
				})
		end
		return t
	end

	append_all(skin.destination, VertGauge())

	--[[ for i = 1, 30 do
	table.insert(skin.destination, {id = "gajga0", dst = {
		{x = 1671, y = 476 - 14  + 14 * i + 2 * (i - 1), w = 28, h = 14, a = 63}
	}})
	table.insert(skin.destination, {id = "gajga0", draw = function() return procent_gajgi > 2 * (i - 1) end, dst = {
		{x = 1671, y = 476 - 14 + 14 * i + 2 * (i - 1), w = 28, h = 14}
	}})
end
for i = 31, 40 do
	table.insert(skin.destination, {id = "gajga60", dst = {
		{x = 1671, y = 476 - 14  + 14 * i + 2 * (i - 1), w = 28, h = 14, a = 63}
	}})
	table.insert(skin.destination, {id = "gajga60", draw = function() return procent_gajgi > 2 * (i - 1) end, dst = {
		{x = 1671, y = 476 - 14  + 14 * i + 2 * (i - 1), w = 28, h = 14}
	}})
end
for i = 41, 50 do
	table.insert(skin.destination, {id = "gajga80", dst = {
		{x = 1671, y = 476 - 14  + 14 * i + 2 * (i - 1), w = 28, h = 14, a = 63}
	}})
	table.insert(skin.destination, {id = "gajga80", draw = function() return procent_gajgi > 2 * (i - 1) end, dst = {
		{x = 1671, y = 476 - 14  + 14 * i + 2 * (i - 1), w = 28, h = 14}
	}})
end ]]

	--[[ append_all(skin.destination, {
	{id = "gajga80", dst = {
		{x = 1671, y = 798, w = 14, h = 14, a = 63}
	}},
	{id = "gajga80", draw = function() return procent_gajgi == 100 end, dst = {
		{x = 1671, y = 798, w = 14, h = 14}
	}}}) ]]


	append_all(skin.destination, {
		{ id = "judge" },
		--	{id = "copyduck"},
		--	{id = "copyduck-n"},
		--[[ 	{id = "itg-f"},
	{id = "itg-s"}, ]]
		--[[ 	{id = "prediction", filter = 1, dst = {
		{time = 0, x = 0, y = 0, w = 88, h = 150},
		{time = 500}
	}},
	{id = "prediction_afterdot", filter = 1, dst = {
		{time = 0, x = 528, y = 0, w = 88, h = 150},
		{time = 500}
	}}, ]]
		--[[ 	{id = "judge-fast", blend = 1, filter = 1, op = {1242}, timer = 46, loop = -1, dst = {
		{time = 0, x = 1220, y = 797, w = 120, h = 36},
		{time = 500}
	}},
	{id = "judge-slow", blend = 1, filter = 1, op = {1243}, timer = 46, loop = -1, dst = {
		{time = 0, x = 1220, y = 797, w = 120, h = 36},
		{time = 500}
	}}, ]]
		{
			id = "judge-fast-2x",
			blend = 1,
			filter = 1,
			op = { 1242 },
			timer = 46,
			loop = -1,
			offsets = { 3, 69 },
			dst = {
				{ time = 0,  x = 1205, y = 795, w = 150, h = 40 },
				{ time = 500 }
			}
		},
		{
			id = "judge-slow-2x",
			blend = 1,
			filter = 1,
			op = { 1243 },
			timer = 46,
			loop = -1,
			offsets = { 3, 69 },
			dst = {
				{ time = 0,  x = 1205, y = 795, w = 150, h = 40 },
				{ time = 500 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 350, h = 1, acc = 2, a = 63 },
				{ time = 1850, y = 1163, h = 2 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 1132 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723 + 26, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 1132 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723 + 52, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 1132 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 350, h = 1, acc = 2, a = 63 },
				{ time = 1850, y = 1091, h = 2 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 1060 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723 + 26, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 1060 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 350, h = 1, acc = 2, a = 63 },
				{ time = 1850, y = 1019, h = 2 }
			}
		},
		{
			id = "a",
			loop = 1850,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 36, h = 32, acc = 2, a = 63 },
				{ time = 1850, y = 988 }
			}
		},
		--[[ 	{id = "graphframe", loop = 800, blend = 1, filter = 1, op = {32}, dst = {
		{time = 600, x = 2071, y = 286, w = 344, h = 1032 - 378 * 2, a = 0},
		{time = 800, x = 1727, a = 255}
	}}, ]]
		{
			id = "graph-end",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1751, y = 576, w = 84, h = 0, acc = 2, a = 100, r = 150, g = 150, b = 150 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "graph-end2",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1749, y = 576, w = 88, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "graph-now",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1751, y = 576, w = 84, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "mybest-bg",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1855, y = 576, w = 84, h = 0, acc = 2, a = 100, r = 150, g = 150, b = 150 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "target-bg",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1961, y = 576, w = 84, h = 0, acc = 2, a = 100, r = 150, g = 150, b = 150 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "mybest-bg2",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1853, y = 576, w = 88, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "target-bg2",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1959, y = 576, w = 88, h = 0, acc = 2, },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "graph-target",
			loop = 800,
			op = { 32 },
			dst = {
				{ time = 600, w = 336,  h = 60, y = 324, x = 2076, a = 0 },
				{ time = 800, x = 1732, a = 255 }
			}
		},
		{
			id = "graph-mybest",
			loop = 800,
			op = { 32 },
			dst = {
				{ time = 600, w = 336,  h = 60, y = 426, x = 2076, a = 0 },
				{ time = 800, x = 1732, a = 255 }
			}
		},
		{
			id = "graph-current",
			loop = 800,
			op = { 32 },
			dst = {
				{ time = 600, w = 336,  h = 60, y = 497, x = 2076, a = 0 },
				{ time = 800, x = 1732, a = 255 }
			}
		},
		{
			id = "graph-text",
			loop = 800,
			op = { 32 },
			dst = {
				{ time = 600, w = 344,  h = 272, y = 286, x = 2076, a = 0 },
				{ time = 800, x = 1732, a = 255 }
			}
		},
		{
			id = "mybest-now",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1855, y = 576, w = 84, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "mybest-first",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32, 100 },
			dst = {
				{ time = 1350, x = 1855, y = 576, w = 84, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = "target-now",
			blend = 1,
			filter = 1,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1961, y = 576, w = 84, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 1, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 2073, y = 576, w = -1, h = 0, acc = 2 },
				{ time = 1850, h = 660 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 350, h = 1, acc = 2 },
				{ time = 1850 }
			}
		},
		{
			id = -111,
			loop = 1850,
			op = { 32 },
			dst = {
				{ time = 1350, x = 1723, y = 576, w = 350, h = 1, acc = 2 },
				{ time = 1850, y = 1236 }
			}
		},
		{
			id = "ex-now-2x",
			loop = 1550,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1929, y = 512, w = 30, h = 36, a = 0 },
				{ time = 1550, a = 255 }
			}
		},
		{
			id = "ex-best-2x",
			loop = 1550,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1929, y = 442, w = 30, h = 36, a = 0 },
				{ time = 1550, a = 255 }
			}
		},
		{
			id = "ex-target-2x",
			loop = 1550,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1929, y = 340, w = 30, h = 36, a = 0 },
				{ time = 1550, a = 255 }
			}
		},
		{
			id = "diff-best-2x",
			loop = 1550,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1929, y = 392, w = 30, h = 36, a = 0 },
				{ time = 1550, a = 255 }
			}
		},
		{
			id = "diff-target-2x",
			loop = 1550,
			op = { 32 },
			filter = 1,
			dst = {
				{ time = 1350, x = 1929, y = 290, w = 30, h = 36, a = 0 },
				{ time = 1550, a = 255 }
			}
		},
		{
			id = "ghost-n-2x",
			blend = 1,
			filter = 1,
			timer = 40,
			offsets = { 3, 69 },
			op = { 32 },
			dst = {
				{ time = 0, x = 1671 + 42, y = 715, w = 30, h = 36 }
			}
		},
		{
			id = "mainbpm",
			blend = 1,
			filter = 1,
			loop = 1200,
			dst = {
				{ time = 850,  x = 1193, y = 350, w = 58, h = 44, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		{
			id = "minbpm",
			blend = 1,
			filter = 1,
			loop = 1200,
			op = { 177 },
			dst = {
				{ time = 850,  x = 1065, y = 350, w = 38, h = 32, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		{
			id = "maxbpm",
			blend = 1,
			filter = 1,
			loop = 1200,
			op = { 177 },
			dst = {
				{ time = 850,  x = 1381, y = 350, w = 38, h = 32, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		{
			id = "mainbpm-t",
			blend = 1,
			filter = 1,
			loop = 1200,
			dst = {
				{ time = 850,  x = 1222, y = 398, w = 116, h = 34, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		{
			id = "minbpm-t",
			blend = 1,
			filter = 1,
			loop = 1200,
			op = { 177 },
			dst = {
				{ time = 850,  x = 1090, y = 398, w = 76, h = 28, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		{
			id = "maxbpm-t",
			blend = 1,
			filter = 1,
			loop = 1200,
			op = { 177 },
			dst = {
				{ time = 850,  x = 1390, y = 398, w = 76, h = 28, a = 0 },
				{ time = 1200, a = 255 }
			}
		},
		-- everything button-able
		{ id = "ribbon_random",                dst = { { x = ribbon.x, y = ribbon.y, w = ribbon.w, h = ribbon.h } } },
		{ id = "ribbon_gauge",                 dst = { { x = ribbon.x + ribbon.w, y = ribbon.y, w = ribbon.w, h = ribbon.h } } },
		{ id = "ribbon_ln",                    op = { 173 },                                                                       dst = { { x = ribbon.x, y = ribbon.y + get_raise(), w = ribbon.w, h = ribbon.h } } },
		-- GAS draws over gauge
		{ id = "ribbon_gas",                   dst = { { x = ribbon.x + ribbon.w, y = ribbon.y, w = ribbon.w, h = ribbon.h } } },
		-- difficulties
		{ id = "ribbon_diff_" .. get_diff(),   dst = { { x = ribbon.x + ribbon.w * 2, y = ribbon.y, w = ribbon.w, h = ribbon.h } } },
		-- autoplay and replay
		{ id = "ribbon_" .. get_play(),        dst = { { x = ribbon.x + ribbon.w * 3, y = ribbon.y, w = ribbon.w, h = ribbon.h } } },
		-- stage (i couldn't get this to work)
		{ id = "ribbon_stage_" .. get_stage(), op = { 290 },                                                                       dst = { { x = ribbon.x + ribbon.w * 2, y = ribbon.y + get_raise(), w = ribbon.w, h = ribbon.h } } },
		{
			id = "song-progress-bar",
			dst = {
				{ time = 0, x = playfieldOrigin - 25, y = 476, w = 23, h = 2048, a = 255 }
			}
		},
		{
			id = "song-progress-start",
			dst = {
				{ time = 0, x = playfieldOrigin - 25, y = 1440 - 35, w = 23, h = 35, a = 255 },
			}
		},
		{
			id = "song-progress",
			loop = 1200,
			dst = {
				{ time = 0,    x = playfieldOrigin - 21, y = 1440 - 70 - 13, w = 16, h = 52, a = 0, acc = 2 },
				{ time = 500,  a = 255 },
				{ time = 1200, y = 1440 - 70 - 13 }
			}
		},
		-- {
		-- 	id = "table",
		-- 	blend = 1,
		-- 	filter = 2,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 400, w = 850, h = 640, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 31 }
		-- 	}
		-- },
		-- {
		-- 	id = "title",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 640, w = 850, h = 160, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 255 }
		-- 	}
		-- },
		-- {
		-- 	id = "genre",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 800, w = 850, h = 44, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 255 }
		-- 	}
		-- },
		-- {
		-- 	id = "subtitle",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 608, w = 850, h = 60, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 255 }
		-- 	}
		-- },
		-- {
		-- 	id = "artist",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 468, w = 850, h = 60, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 255 }
		-- 	}
		-- },
		-- {
		-- 	id = "subartist",
		-- 	blend = 1,
		-- 	filter = 1,
		-- 	loop = 750,
		-- 	op = { 80 },
		-- 	dst = {
		-- 		{ time = 0,   x = 1280, y = 40 + 852, w = 850, h = 40, r = 127, g = 127, b = 127, a = 0 },
		-- 		{ time = 500 },
		-- 		{ time = 750, a = 255 }
		-- 	}
		-- },
		{
			id = "table",
			blend = 1,
			filter = 2,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 900, w = 869, h = 1, a = 96 },
			}
		},
		{
			id = "genre",
			blend = 1,
			filter = 1,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 870, w = 869, h = 1, a = 112 },
			}
		},
		{
			id = "title",
			blend = 1,
			filter = 1,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 832, w = 869, h = 1, a = 128 },
			}
		},
		{
			id = "subtitle",
			blend = 1,
			filter = 1,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 770, w = 869, h = 1, a = 128 },
			}
		},
		{
			id = "artist",
			blend = 1,
			filter = 1,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 736, w = 869, h = 1, a = 112 },
			}
		},
		{
			id = "subartist",
			blend = 1,
			filter = 1,
			loop = 0,
			dst = {
				{ time = 0, x = 435, y = 710, w = 869, h = 1, a = 96 },
			}
		},
		{
			id = "badge",
			blend = 1,
			filter = 1,
			loop = 1000,
			dst = {
				{ time = 800,  x = 1040, w = 480, h = 80, a = 0 },
				{ time = 1000, a = 185 }
			}
		},
		{
			id = "badge",
			blend = 2,
			filter = 1,
			timer = 140,
			dst = {
				{ time = 0,    x = 1040, w = 480, h = 80, a = 0, r = 85 },
				{ time = 1000, a = 85,   r = 255 }
			}
		},
		{
			id = "judgestats-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1200, x = 1760, y = 60, w = 290, h = 214, a = 0 },
				{ time = 1500, a = 255 }
			}
		},
		{
			id = "judgestats-pgreat-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1767, y = 246, w = 116, h = 24, a = 0 },
				{ time = 1600, a = 255 },
			}
		},
		{
			id = "stats-pg-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 240, w = 30, h = 36 }
			}
		},
		{
			id = "stats-gr-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 204, w = 30, h = 36 }
			}
		},
		{
			id = "stats-gd-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 168, w = 30, h = 36 }
			}
		},
		{
			id = "stats-bd-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 132, w = 30, h = 36 }
			}
		},
		{
			id = "stats-pr-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 96, w = 30, h = 36 }
			}
		},
		{
			id = "stats-rt-2x",
			blend = 1,
			filter = 1,
			loop = 1500,
			op = { 32 },
			dst = {
				{ time = 1500, x = 1923, y = 60, w = 30, h = 36 }
			}
		},
		{
			id = "judgegraph",
			loop = 1000,
			op = { 80 },
			dst = {
				{ time = 800,  x = 903, y = 100, w = 754, h = 200, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
		{
			id = "bpmgraph",
			loop = 1000,
			op = { 177, 80 },
			dst = {
				{ time = 800,  x = 903, y = 100, w = 754, h = 200, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
		{
			id = -111,
			loop = 1000,
			dst = {
				{ time = 800,  x = 901, y = 98, w = 758, h = 2, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
		{
			id = -111,
			loop = 1000,
			dst = {
				{ time = 800,  x = 901, y = 300, w = 758, h = 2, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
		{
			id = -111,
			loop = 1000,
			dst = {
				{ time = 800,  x = 901, y = 100, w = 2, h = 200, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
		{
			id = -111,
			loop = 1000,
			dst = {
				{ time = 800,  x = 1657, y = 100, w = 2, h = 200, a = 0 },
				{ time = 1000, a = 127 }
			}
		},
	})

	local function timer_key_bomb(index)
		if index == 8 then
			return 50
		else
			return 50 + index
		end
	end

	local function timer_key_hold(index)
		if index == 8 then
			return 70
		else
			return 70 + index
		end
	end

	local function get_hell(i)
		mult = 0
		if i % 2 == 0 then
			mult = 0
		end
		if i % 2 == 1 then
			mult = 1
		end
		if i == 8 then
			mult = 2
		end
		return mult
	end

	for i = 1, 8 do
		table.insert(skin.image,
			{
				id = "hell-" .. timer_key_hold(i),
				src = "src-hell",
				y = 302 * get_hell(i),
				w = 7550,
				h = 302,
				divx = 25,
				cycle = 450,
				timer =
					timer_key_hold(i),
			})
		table.insert(skin.destination,
			{
				id = "hell-" .. timer_key_hold(i),
				timer = timer_key_hold(i),
				blend = 2,
				filter = 1,
				offset = 3,
				dst = {
					{ time = 0,  x = playfieldOrigin + geo.note_x[i] - 498 + geo.note_w[i] / 2, w = 996, h = 996 },
					{ time = 250 }
				}
			})
	end

	for i = 1, 8 do
		table.insert(skin.image,
			{ id = "bomb" .. i, src = "src-bomb", w = 4608, h = 1536, divx = 9, divy = 3, cycle = 433, timer = timer_key_bomb(i) })
		table.insert(skin.image,
			{
				id = "bomb" .. i .. "hell",
				src = "src-bomb",
				w = 4608,
				h = 1536,
				divx = 9,
				divy = 3,
				cycle = 433,
				timer =
					timer_key_bomb(i)
			})
		table.insert(skin.destination,
			{
				id = "bomb" .. i,
				timer = timer_key_bomb(i),
				blend = 2,
				filter = 1,
				loop = -1,
				offset = 3,
				dst = {
					{ time = 0,  x = playfieldOrigin + geo.note_x[i] - 270 + geo.note_w[i] / 2, y = 210, w = 540, h = 540, blend = 2 },
					{ time = 250 }
				}
			})
		table.insert(skin.destination,
			{
				id = "bomb" .. i,
				timer = timer_key_hold(i),
				blend = 2,
				filter = 1,
				loop = -1,
				offset = 3,
				dst = {
					{ time = 0,   x = playfieldOrigin + geo.note_x[i] - 270 + geo.note_w[i] / 2, y = 210, w = 540, h = 540, blend = 2 },
					{ time = 2500 }
				}
			})
	end

	append_all(skin.destination, {
		{
			id = "lilith",
			filter = 1,
			timer = 41,
			dst = {
				{ time = 0, x = 903 - 280, y = 65, w = 280, h = 280 }
			}
		}
		--[[ 	{id = "pmchara", filter = 1, dst = {
		{time = 0, x = 903 - 280, y = 65, w = 167, h = 271}
	}} ]]
	})

	append_all(skin.destination, {
		{
			id = "clear",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x,      y = g.lane_origin_y + 280, w = g.lanes_width, h = 48, a = 0 },
				{ time = 100, y = g.lane_origin_y + 300, a = 255 }
			}
		},
		{
			id = "grade",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x,      y = g.lane_origin_y + 180, w = g.lanes_width, h = 72, a = 0 },
				{ time = 100, y = g.lane_origin_y + 200, a = 255 }
			}
		},
		{
			id = "fa-n",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x - g.lanes_width / 4, y = g.lane_origin_y + 180, w = g.lanes_width, h = 48, r = 0, g = 0, b = 255, a = 0 },
				{ time = 100, y = g.lane_origin_y + 200,                a = 192 }
			}
		},
		{
			id = "fast",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x - g.lanes_width / 4, y = g.lane_origin_y + 230, w = g.lanes_width, h = 24, r = 0, g = 0, b = 255, a = 0 },
				{ time = 100, y = g.lane_origin_y + 250,                a = 144 }
			}
		},
		{
			id = "sl-n",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x + g.lanes_width / 4, y = g.lane_origin_y + 180, w = g.lanes_width, h = 48, r = 255, g = 0, b = 0, a = 0 },
				{ time = 100, y = g.lane_origin_y + 200,                a = 192 }
			}
		},
		{
			id = "slow",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x + g.lanes_width / 4, y = g.lane_origin_y + 230, w = g.lanes_width, h = 24, r = 255, g = 0, b = 0, a = 0 },
				{ time = 100, y = g.lane_origin_y + 250,                a = 144 }
			}
		},

		{
			id = "ex-n",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x,      y = g.lane_origin_y + 80, w = g.lanes_width, h = 48, a = 0 },
				{ time = 100, y = g.lane_origin_y + 100, a = 255 }
			}
		},
		{
			id = "ex",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x,      y = g.lane_origin_y + 130, w = g.lanes_width, h = 24, a = 0 },
				{ time = 100, y = g.lane_origin_y + 150, a = 144 }
			}
		},
		{
			id = "cb-n",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x - g.lanes_width / 4, y = g.lane_origin_y + 80, w = g.lanes_width, h = 48, a = 0 },
				{ time = 100, y = g.lane_origin_y + 100,                a = 192 }
			}
		},
		{
			id = "cb",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x - g.lanes_width / 4, y = g.lane_origin_y + 130, w = g.lanes_width, h = 24, a = 0 },
				{ time = 100, y = g.lane_origin_y + 150,                a = 144 }
			}
		},
		{
			id = "bp-n",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x + g.lanes_width / 4, y = g.lane_origin_y + 80, w = g.lanes_width, h = 48, a = 0 },
				{ time = 100, y = g.lane_origin_y + 100,                a = 192 }
			}
		},
		{
			id = "bp",
			filter = 1,
			timer = 143,
			offsets = { 3 },
			loop = 100,
			dst = {
				{ time = 0,   x = g.lanes_center_x + g.lanes_width / 4, y = g.lane_origin_y + 130, w = g.lanes_width, h = 24, a = 0 },
				{ time = 100, y = g.lane_origin_y + 150,                a = 144 }
			}
		},

		{
			id = "fail-gradient",
			filter = 1,
			timer = 10101,
			loop = 500,
			blend = 2,
			dst = {
				{ time = 0,   x = g.lane_origin_x, y = g.lane_origin_y, w = g.lanes_width / 5, h = 1080 - g.lane_origin_y, a = 255 },
				{ time = 500, a = 0 }
			}
		},
		{
			id = "fail-gradient",
			filter = 1,
			timer = 10101,
			loop = 500,
			blend = 2,
			dst = {
				{ time = 0,   x = g.lane_origin_x + g.lanes_width, y = g.lane_origin_y, w = 0 - g.lanes_width / 5, h = 1080 - g.lane_origin_y, a = 255 },
				{ time = 500, a = 0 }
			}
		}
	})

	append_all(skin.destination, {
		{
			id = -110,
			loop = 800,
			dst = {
				{ time = 0,   acc = 2,  w = 1280, h = 1440 },
				{ time = 800, x = -1280 }
			}
		},
		{
			id = -110,
			loop = 800,
			dst = {
				{ time = 0,   acc = 2, x = 1280, w = 1280, h = 1440 },
				{ time = 800, x = 2560 }
			}
		},
		{
			id = "kurwa",
			loop = 100,
			filter = 4,
			timer = 3,
			dst = {
				{ time = 0,   x = playfieldOrigin, y = 476, w = playfieldWidth, h = playfieldWidth * 0.908, a = 0 },
				{ time = 100, a = 255 }
			}
		},
		{
			id = -110,
			loop = 1000,
			timer = 3,
			dst = {
				{ time = 0,    w = 2560, h = 1440, a = 0 },
				{ time = 900 },
				{ time = 1000, a = 255 }
			}
		},
		{
			id = -110,
			loop = 100,
			timer = 2,
			dst = {
				{ time = 0,   w = 2560, h = 1440, a = 0 },
				{ time = 100, a = 255 }
			}
		},

	})
	print("szerokosc to" .. tostring(playfieldWidth))

	--eof
	return skin
end

return {
	header = header,
	main = main
}
