#78 Add text different adjust types

This commit is contained in:
Insality
2021-10-20 20:24:31 +03:00
parent a501d3418b
commit 4ef8316949
12 changed files with 1449 additions and 22 deletions

View File

@@ -0,0 +1,37 @@
name: "texts_adjust"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"texts_adjust\"\n"
" component: \"/example/examples/texts/texts_adjust/texts_adjust.gui\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
"}\n"
""
position {
x: 0.0
y: 0.0
z: 0.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale3 {
x: 1.0
y: 1.0
z: 1.0
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
local druid = require("druid.druid")
local const = require("druid.const")
function init(self)
self.druid = druid.new(self)
self.texts = {
self.druid:new_text("text_scale", nil, const.TEXT_ADJUST.DOWNSCALE),
self.druid:new_text("text_trim", nil, const.TEXT_ADJUST.TRIM),
self.druid:new_text("text_no_adjust", nil, const.TEXT_ADJUST.NO_ADJUST),
self.druid:new_text("text_scale_limited", nil, const.TEXT_ADJUST.DOWNSCALE_LIMITED)
:set_minimal_scale(0.5),
self.druid:new_text("text_scroll", nil, const.TEXT_ADJUST.SCROLL),
self.druid:new_text("text_scroll_scale", nil, const.TEXT_ADJUST.SCALE_THEN_SCROLL)
:set_minimal_scale(0.5)
}
local initial_texts = {}
local text_sizes = {}
for _, text in pairs(self.texts) do
initial_texts[text] = text.last_value
text_sizes[text] = 0
end
timer.delay(0.25, true, function()
for _, text in pairs(self.texts) do
local text_string = string.sub(initial_texts[text], 1, text_sizes[text])
text_sizes[text] = text_sizes[text] + 1
if text_sizes[text] > #initial_texts[text] then
text_sizes[text] = 0
end
text:set_to(text_string)
end
end)
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end